<template>
	<view class="search-box">
		<view class="search-box-content">
			<view class="box-left">
				<view class="search-icon">
					<image src="../../static/home/search@2x.png" mode="widthFix"></image>
				</view>
				<view class="search-input">
					<input type="text" v-model="keyword" placeholder="搜索您想要的课程"/>
				</view>
			</view>
			<view class="box-button">
				<button @click="jumpSearch">搜索</button>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		props:{
			search:{
				type:String,
				default:''
			}
		},
		watch:{
			search:{
				handler(val){
					this.keyword =val
				},
				immediate: true
			}
		},
		data() {
			return {
				keyword: ""
			}
		},
		methods: {
			jumpSearch() {
				console.log('????', this.keyword)
				this.$emit('searchEmit',this.keyword)
			}
		}
	}
</script>

<style>
	.search-box {
		padding: 30rpx;
		background-color: #FFFFFF;
	}
	.search-box-content {
		padding-left: 30rpx;
		display: flex;
		align-items: center;
		justify-content: space-between;
		border: 1px solid #F53939;
		border-radius: 80rpx;
	}
	
	.box-left {
		flex: 1;
		display: flex;
		align-items: center;
	}
	
	.search-icon image{
		width: 30rpx;
	}
	.search-input {
		margin-left: 15rpx;
	}
	.search-input input {
		color: #BFBFBF;
		font-size: 28rpx;
	}
	
	.box-button{
		border: 1px solid #fff;
		background: #F53939;
		border-radius: 80rpx;
		padding: 0 40rpx;
	}
	.box-button button {
		font-size: 30rpx;
		color: #fff;
		height: 75rpx;
		line-height: 75rpx;
	}
</style>
